/*
 * File:    DocumentBody.java
 * Created: 23-Mar-2009
 * Version: $Id$
 *
 * COPYRIGHT (C) 2009, Bitgate Mobile, LLC.  All Rights Reserved.
 *
 * software@bitgatemobile.com
 */

package com.webplasm.render.tags.internal;

import java.util.Arrays;
import java.util.List;

import com.webplasm.context.RenderContext;
import com.webplasm.render.engine.RenderException;
import com.webplasm.render.tags.TagInterface;
import com.webplasm.render.tags.WrappedNode;

import static com.bitgate.util.debug.Debug.debug;

public class DocumentBody extends WrappedNode implements TagInterface {
	private static final String DESCRIPTION = "Document processing tag, controls the output of the document after rendering.";
	
	public String getNamespace() {
		return "u";
	}

	public List<String> getAttributes() {
		return Arrays.asList("contenttype");
	}
	
	public List<String> getManagedNodes() {
		return null;
	}

	public String getDescription() {
		return DESCRIPTION;
	}

	@Override
	public StringBuffer render(RenderContext rContext) throws RenderException {
		if (elements.get("contenttype") != null) {
			rContext.setContentType(elements.get("contenttype"));
			debug("Content-type set to '" + elements.get("contenttype") + "'");
		}
		
		return new StringBuffer(super.render(rContext).toString());
	}

}